package com.smartrm.globalinfrcore.cmd.interceptor;

import com.smartrm.globalinfrcore.cmd.AbstractCommandContext;
import com.smartrm.globalinfrcore.cmd.Command;
import com.smartrm.globalinfrcore.cmd.CommandConfig;
import org.springframework.stereotype.Component;

/*
 * @program: common-starters
 * @description: 拦截器执行器：在这个拦截器会真正的执行命令，然后递归向上
 * @author: houhong
 * @create: 2023-01-11 21:34
 */
@Component
public class InvokerInterceptor implements CommandInterceptor {


    @Override
    public CommandInterceptor getNext() {
        return null;
    }

    @Override
    public void setNext(CommandInterceptor next) {
        throw new UnsupportedOperationException("this invokerInterceptor should be the finally commandIntercetor");
    }

    @Override
    public <T> T execute(AbstractCommandContext commandContext,CommandConfig config, Command<T> command) throws Exception {
        return command.execute(commandContext);
    }
}